package com.example.stock.controller;
/**
 * @Author Justice
 * @Date 2019/4/8 16:17
 * @Version 1.0
 */

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.stock.eo.ProBar399300Eo;
import com.example.stock.eo.StockDetailEo;
import com.example.stock.mapper.ProBar300Mapper;
import com.example.stock.mapper.StockDetailMapper;
import com.example.stock.service.ProBar300Service;
import com.example.stock.service.StockDetailService;
import com.example.stock.vo.DataVo;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@RestController
public class ComController {
  @Resource
  private JdbcTemplate jdbcTemplate;
  @Resource
  private StockDetailMapper userInfoMapper;
  @Resource
  private ProBar300Service proBar300Service;
  @Resource
  private ProBar300Mapper proBar300Mapper;
  @Resource
  private StockDetailService stockDetailService;
   
  @RequestMapping("/u")
  public List<Map<String, Object>> getDbType(){
    String sql = "select * from sys_user";
    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
    return list;
  }

  @RequestMapping("/m")
  public Object mlist(){
    return JSON.toJSONString(userInfoMapper.selectList(null));
  }

  @RequestMapping("/n")
  public Object queryM(){
    return JSON.toJSONString(
            userInfoMapper.selectList(
                    Wrappers.<StockDetailEo>lambdaQuery()
                    .select(StockDetailEo::getAmount, StockDetailEo::getAmount)
                    .eq(StockDetailEo::getCode,0)
            )

    );
  }
  @RequestMapping("compare")
  public Object compare(){
    List<DataVo> rowData30 = stockDetailService.getRowData30();
    List<DataVo> proBar399300Eos = proBar300Service.getRowData30();
    System.out.println(rowData30.size());
    System.out.println(proBar399300Eos.size());
    for (int i = 0; i < rowData30.size(); i++) {
      DataVo dataVo = rowData30.get(i);
      DataVo proBar399300Eo = proBar399300Eos.get(i);
      if (!dataVo.getTime().equals(proBar399300Eo.getTime())) {
        System.out.println(dataVo);
        System.out.println(proBar399300Eo);
        return i;
      }
      if (!dataVo.getBigDecimal().equals(proBar399300Eo.getBigDecimal())) {
        System.out.print(dataVo);
        System.out.println(proBar399300Eo.getBigDecimal());
      }
    }
    return "success";
  }
}